#ifndef WIDGET_H
#define WIDGET_H
 
#include <QThread>
#include <QAbstractSocket>
#include "define.h"
class QTcpSocket;
class QFile; 
 
class CClient : public QThread
{
    Q_OBJECT
 
public:
    explicit CClient();
    ~CClient();
    
    void send(QString ipAddress, int port, QStringList filenames);

protected:
	void run();
    void transferNext();
 
protected slots:
    void send();
    void connected();
    void startTransfer();
    void updateClientProgress(qint64);
    void displayError(QAbstractSocket::SocketError);

signals:
    void sigCliStatus(int code, QString msg); //code: 1 status 2 process 3 error
 
private:
    QTcpSocket *m_tcpClient;
    QFile *m_localFile;
    qint64 m_totalBytes;
    qint64 m_bytesWritten;
    qint64 m_bytesToWrite;
    qint64 m_payloadSize;
    QStringList m_fileNames;
    QString m_ipAddress;
    int m_port;
    QByteArray m_outBlock;
    int m_file_idx;
};
 
#endif // WIDGET_H
